<!--
 * @Description: 上传组件
 * @Autor: dengyongliang
 * @Date: 2021-04-14 16:12:55
 * @LastEditors: dengyongliang
 * @LastEditTime: 2021-08-17 17:25:22
-->
<template>
  <div style="padding: 20px">
    <el-divider content-position="left">text</el-divider>
    <si-upload :upload="upload" />
    <el-divider content-position="left">picture</el-divider>
    <si-upload :upload="upload2" />
  </div>
</template>

<script>
export default {
  name: 'DemoUpload',
  components: {},
  props: [],
  data() {
    return {
      upload: {
        multiple: false,
        limit: 3,
        action: '',
        accept: '.pdf,.rar',
        'list-type': 'text',
        'http-request': this.handleUpload,
        'file-list': [
          {
            name: 'food.pdf',
            url:
              'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
          },
          {
            name: 'food2.zip',
            url:
              'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
          }
        ]
      },
      upload2: {
        multiple: true,
        limit: 3,
        action: '',
        accept: '.jpg,.png',
        'list-type': 'picture',
        'http-request': this.handleUpload,
        'file-list': [
          {
            name: 'food.pdf',
            url:
              'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
          },
          {
            name: 'food2.zip',
            url:
              'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
          }
        ]
      }
    }
  },
  mounted() {},
  methods: {
    handleUpload(file) {
      console.log(file)
      const imgUploadForm = new FormData()
      imgUploadForm.append('file', file.file)
      // uploadFile(imgUploadForm).then(res => {
      //   this.formData.picture = res.fileUrl
      // })
    }
  }
}
</script>

<style lang="scss" scoped>
.content-page {
  .tab-content {
    width: 100%;
    padding: 20px;
  }
}
</style>
